import React, { useEffect } from "react"; import { useRouter } from "next/router"; import { api } from "@/src/utils/api"; import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture"; import ContainerPage from "@/src/components/layouts/container-page"; import { ActionButton } from "@/src/components/ActionButton"; import { SubHeader } from "@/src/components/layouts/header"; import { Button } from "@/src/components/ui/button"; import { ApiKeyRender } from "@/src/features/public-api/components/CreateApiKeyButton"; import { type RouterOutput } from "@/src/utils/types"; import { useState } from "react"; const TracingSetup = ({ projectId, hasTracingConfigured, }: { projectId: string; hasTracingConfigured?: boolean; }) => { const [apiKeys, setApiKeys] = useState< RouterOutput["projectApiKeys"]["create"] | null >(null); const utils = api.useUtils(); const mutCreateApiKey = api.projectApiKeys.create.useMutation({ onSuccess: (data) => { utils.projectApiKeys.invalidate(); setApiKeys(data); }, }); const createApiKey = async () => { try { await mutCreateApiKey.mutateAsync({ projectId }); } catch (error) { console.error("Error creating API key:", error); } }; return (
{apiKeys ? ( ) : (

You need to create an API key to start tracing your application. You can create more keys later in the project settings.

Manage API keys
)}

Langfuse relies on OpenTelemetry to instrument your application and export LLM application/agent traces to Langfuse. You can use one of our SDKs or 50+ framework integrations. Please follow the quickstart in the documentation to add Langfuse to your application.

Instrumentation Quickstart
); }; export default function TracesSetupPage() { const router = useRouter(); const projectId = router.query.projectId as string; // Check if the user has tracing configured const { data: hasTracingConfigured } = api.traces.hasTracingConfigured.useQuery( { projectId }, { enabled: !!projectId, refetchInterval: 5000, trpc: { context: { skipBatch: true, }, }, }, ); const capture = usePostHogClientCapture(); useEffect(() => { if (hasTracingConfigured !== undefined) { capture("onboarding:tracing_check_active", { active: hasTracingConfigured, }); } }, [hasTracingConfigured, capture]); return (
); }